package com.irdstudio.smcenter.agent.boot;

import java.sql.SQLException;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;

import com.irdstudio.smcenter.agent.utils.SpringContextUtils;
import com.irdstudio.smcenter.core.init.AgentResourceLoader;
import com.irdstudio.smcenter.core.plugin.hsf.HsfServiceConfig;
import com.taobao.pandora.boot.PandoraBootstrap;

/**
 * <p>Agent启动入口,根据属性文件中的参数分别支持dubbo,hsf及local模式的agent</p>
 * @author fuzm
 * @date 2018-06-15
 */
@SpringBootApplication
@ComponentScan(basePackages = {"com.irdstudio.smcenter.agent"})
public class HSFAgentBoot {

	public static void main(String[] args) throws SQLException {

		// 加载配置
		AgentResourceLoader.me().start();
		System.out.println("正在以agent for hsf模式启动...");

		// HSF所必须的Pandora容器初始化，(在POM文件中需引用)
		PandoraBootstrap.run(args);
		ApplicationContext context = SpringApplication.run(HSFAgentBoot.class, args);
		SpringContextUtils.setApplicationContext(context);

		// 初始化hsf服务
		HsfServiceConfig.init();

		PandoraBootstrap.markStartupAndWait();

	}
}
